package Filter;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;

@WebFilter("/login/dgut")
public class Dgut_Filter implements Filter {

    public void destroy() {

    }
    public void init(FilterConfig config) throws ServletException {

    }
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res = (HttpServletResponse) response;

        String token=req.getParameter("token");
        if (token != null) {
            chain.doFilter(req,res);
            //return;
        }
        else {
            res.sendRedirect("https://cas.dgut.edu.cn?appid=javaee&state=STATE");

        }
    }
}
